import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { ColumnType, SPage, TablePageComponent } from '@shared/components/table-page/table-page.component';
import { ApiService } from '@core/services/api';
import { STData } from '@delon/abc';
@Component({
  selector: 'app-service-log',
  templateUrl: './service-log.component.html',
  styles: ['>>>.hidcolumn{width:0;}']
})
export class ServiceLogComponent implements OnInit {
  @ViewChild('st', {static: true})st: TablePageComponent;
  @Input()
  set param(value) {
    this.config.defaultParam = {
      serviceName: value.serviceName
    }
  }
  config: SPage = {
    columns: [
      {
        title: '账号',
        index: 'account',
        filter:{
          type:'string',
          placeholder:'请输入账号'
        }
      },
      {
        title: '操作名称',
        index: 'operation',
        type: ColumnType.tag,
        tag:{
          1:{text:'远程开门'},
          2:{text:'更新卡房资料'},
        },
        filter:{
          placeholder: '请选择操作名称',
          type: 'select',
          items: [
            {label: '远程开门', value: 1},
            {label: '更新卡房资料', value: 2}
          ]
        }
      },
      {
        title:'接口地址',
        index:'apiUrl'
      },
      {
        title:'',
        index:'beginTime',
        type:ColumnType.date,
        className:'hidcolumn',
        filter:{
          placeholder:'开始时间',
          type:'date',
          format:'YYYY-MM-DD 00:00:00'
        }
      },
      {
        title:'',
        index:'endTime',
        type:ColumnType.date,
        className:'hidcolumn',
        filter:{
          placeholder:'结束时间',
          type:'date',
          format:'YYYY-MM-DD 23:59:59'
          
        }
      },
      {
        title:'门禁SN/小程序账号',
        index:'tId',
        filter:{
          type:'string',
          placeholder:'请输入门禁SN/小程序账号'
        }
      },

      {
        title: '请求类型',
        index: 'requestType',
        type: ColumnType.tag,
        tag: {
          1: {text: 'POST', color: 'green'},
          2: {text: 'GET', color: 'blue'},
          3: {text: 'PUT', color: 'orange'},
          4: {text: 'DELETE', color: 'red'}
        },
      },
      {
        title: '操作时间',
        index: 'createTime'
      }
    ],
    reqUrl: '/core/record/inout/page',
  };
  constructor(
    private api: ApiService
  ) { }
  
  dataProcess(data: STData[]){
    console.log(data);
    let returnData = [
      {id:1,account:'账号1',operation:1, createTime:'2021-02-01 2021-02-02',requestType:1,apiUrl:'/page/abc/url',tId:'ab23452'},
      {id:1,account:'账号2',operation:2, createTime:'2021-02-01 2021-02-02',requestType:2,apiUrl:'/page/abc/url',tId:'12314'},
      {id:1,account:'账号3',operation:2, createTime:'2021-02-01 2021-02-02',requestType:3,apiUrl:'/page/abc/url1',tId:'fa2382'},
      {id:1,account:'账号4',operation:1, createTime:'2021-02-01 2021-02-02',requestType:2,apiUrl:'/page/abc/url13',tId:'54225gghs'},
      {id:1,account:'账号5',operation:1, createTime:'2021-02-01 2021-02-02',requestType:3,apiUrl:'/page/abc/url3',tId:'35t3gg'},
      {id:1,account:'账号6',operation:1, createTime:'2021-02-01 2021-02-02',requestType:1,apiUrl:'/page/abc/url232',tId:'gf3456'},
      {id:1,account:'账号7',operation:2, createTime:'2021-02-01 2021-02-02',requestType:2,apiUrl:'/page/abc/ur4',tId:'5345rgag'},
      {id:1,account:'账号8',operation:2, createTime:'2021-02-01 2021-02-02',requestType:4,apiUrl:'/page/abc/url23',tId:'few2324'},
      {id:1,account:'账号9',operation:1, createTime:'2021-02-01 2021-02-02',requestType:2,apiUrl:'/page/abc/url2',tId:'4352greg'},
      {id:1,account:'账号10',operation:2, createTime:'2021-02-01 2021-02-02',requestType:2,apiUrl:'/page/abc/url2',tId:'52fabre'},
      {id:1,account:'账号11',operation:1, createTime:'2021-02-01 2021-02-02',requestType:1,apiUrl:'/page/abc/url232',tId:'1238372221'},
      {id:1,account:'账号12',operation:1, createTime:'2021-02-01 2021-02-02',requestType:1,apiUrl:'/page/abc/url232',tId:'5252'},
    ];
    return returnData;
  }

  ngOnInit() {
  }
}
